/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mysweethome.sessionbean;

import java.util.List;
import java.util.UUID;
import javax.ejb.Local;
import javax.ejb.Stateless;
import mysweethome.dao.CustomerDAO;
import mysweethome.entities.Customer;

/**
 *
 * @author johan
 */
@Stateless(name = "customerSEJB", mappedName = "ejb/customerSEJB")
@Local(CustomerBizLocal.class)
public class CustomerBiz extends AbstractBaseEJB implements CustomerBizLocal {

    CustomerDAO cusDAO;
    
    @Override
    public boolean checkLogin(String username, String password) {
        cusDAO = new CustomerDAO(em);
        return cusDAO.checkLogin(username, password);  
    }

    @Override
    public List<Customer> SelectAll() {
        cusDAO = new CustomerDAO(em);
        List<Customer>list=cusDAO.SelectAll();
        return list;
    }

    @Override
    public List<Customer> SearchByID(String ID) {
        cusDAO = new CustomerDAO(em);
        List<Customer>list=cusDAO.SearchByID(ID);
        return list;
    }

    @Override
    public boolean Register(Customer customer) {
        cusDAO = new CustomerDAO(em);
        boolean result=cusDAO.create(customer);
        return result;
    }

    @Override
    public String GenerateID() {
        String id=UUID.randomUUID().toString();
        return id;
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
 
}
